#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct person
{
    char name[20];
    int age;
    float height;
}person;
person *my_realloc(person *p,int size , int new_size);
int main()
{
    person *p = (person*)malloc(sizeof(person));
    if(p == NULL)
    {
        printf("malloc failed\n");
        return 0;
    }
    printf("%p\n",p);
    free(p);
    p =  my_realloc(p, sizeof(person), 128);
    printf("%p\n",p);
    free(p);
    return 0;
}


person *my_realloc(person *p,int size , int new_size)
{
    if(new_size == 0)
    {
        free(p);
        return NULL;
    }
    else if(new_size < size)
    {
        return (person*)malloc(size);
    }
    else
    {
    p = (person*)malloc(new_size);
    return p;
    }

}
